
import React, { useEffect, useState } from "react";
import { Avatar, Button } from "antd-mobile";
import { useNavigate } from "react-router-dom";
import "./index.less";
import { getCurrentUserInfo } from "@/utils/authority";
import { getMessageList } from "./service";

const User: React.FC<any> = () => {
	const navigate = useNavigate();
	const userId = getCurrentUserInfo()?.data?.id;
	const [list, setList] = useState<any>([
		{ id: 1, name: '广安人民政府大门左侧', line: '1', url: '/video/ss1.mp4' },
		{ id: 2, name: '广安人民政府门口右侧', line: '1', url: '/video/ss2.mp4' },
	]);
	const getListData = async () => {
		const params = {
			userId: userId,
		};
		try {
			const { data } = await getMessageList(params);
			setList(data || []);
		} catch { }
	};

	useEffect(() => {
		// getListData();
	}, []);
	const goDetails = (val) => {
		navigate('/equipmentVideo', { state: val })
	};

	return (
		<div className="equipment-contarnier">
			<div className="header">
				<p>物联</p>
			</div>
			<div className="equipment-box">
				{list.map((item) => (
					<div
						className="equipment-box-card"
						key={item.id}
						onClick={() => goDetails(item)}>
						<img className="equipment-box-card-img" src="/images/Supervisory.png" alt="" />
						<div className="equipment-box-card-name">{item?.name || ""}</div>
						<div className="equipment-box-card-line">{item?.line == '1' ? '在线' : '离线' || ""}</div>
					</div>
				))}
			</div>
		</div>
	);
};

export default User;
